<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html>
<!-- 网页使用的语言 -->
<html lang="zh-CN">
    <head>
        <!-- 指定字符集 -->
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>修改用户</title>

        <link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet">
        <script src="${pageContext.request.contextPath}/js/jquery-2.1.0.min.js"></script>
        <script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
        <script>
            //当加载add页面时即发送ajax获取城市信息
            $(function () {
                let cid=${user.city.id};
               // alert(cid);
                //发送ajax请求
                $.get("${pageContext.request.contextPath}/city",function (data) {
                    //alert(data.length);
                    //data是后端响应的json数据
                    for(let i=0;i<data.length;i++){
                        //alert(data[i].id==cid);
                        //1、获取下拉菜单,
                        if(data[i].id==cid){
                            $("#address").append("<option  selected>"+data[i].city+"</option>");
                        }else {
                            $("#address").append("<option>"+data[i].city+"</option>");
                        }

                    }

                },"json")
            })
        </script>
        
    </head>
    <body>
        <div class="container" style="width: 400px;">
        <h3 style="text-align: center;">修改联系人</h3>
        <form action="${pageContext.request.contextPath}/user?method=updateByUser" method="post">
            <%--设置一个隐藏域，来携带id值--%>
            <input type="hidden" name="id" value="${user.id}"/>
          <div class="form-group">
            <label for="name">姓名：</label>
            <input type="text" class="form-control" id="name" name="name"  readonly="readonly" placeholder="请输入姓名" value="${user.name}"/>
          </div>

          <div class="form-group">
            <label>性别：</label>
              <input type="radio" name="gender" ${user.gender==0?"checked":""} value="0"  />男
                <input type="radio" name="gender" ${user.gender==1?"checked":""} value="1"  />女
          </div>

          <div class="form-group">
            <label for="age">年龄：</label>
            <input type="text" class="form-control" id="age"  name="age" placeholder="请输入年龄" value="${user.age}"/>
          </div>

          <div class="form-group">
            <label for="address">籍贯：</label>
             <select name="address" class="form-control" id="address">
               <%-- <option value="广东">广东</option>
                <option value="广西">广西</option>
                <option value="湖南">湖南</option>--%>
            </select>
          </div>

          <div class="form-group">
            <label for="qq">QQ：</label>
            <input type="text" class="form-control" id="qq" name="qq" placeholder="请输入QQ号码" value="${user.qq}"/>
          </div>

          <div class="form-group">
            <label for="email">Email：</label>
            <input type="text" class="form-control" id="email" name="email" placeholder="请输入邮箱地址" value="${user.email}"/>
          </div>

             <div class="form-group" style="text-align: center">
                <input class="btn btn-primary" type="submit" value="提交" />
                <input class="btn btn-default" type="reset" value="重置" />
                <input class="btn btn-default" type="button" value="返回"/>
             </div>
        </form>
        </div>
    </body>
</html>